package com.ruoyi.smile.mapper;

import com.ruoyi.smile.domain.McDynamicComment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 动态评论Mapper接口
 *
 * @author xin
 * @date 2025-03-22
 */
@Mapper
public interface McDynamicCommentMapperPlus
{
    /**
     *  查询指定动态的所有一级评论
     */
    @Select("select " +
            "id," +
            "user_id as userId," +
            "be_comment_id as beCommentId," +
            "content,content_image as contentImage," +
            "content_video as contentVideo," +
            "root_id as rootId,p_id as pId,p_nicke as pNicke," +
            "province,city,like_count as likeCount,is_like as isLike," +
            "is_pinned as isPinned,status,del_flag as delFlag,create_by as createBy," +
            "create_time as createTime  " +
            "from mc_dynamic_comment " +
            "where root_id = 0 and be_comment_id = #{be_comment_id}")
    List<McDynamicComment> list1(Long be_comment_id);



    /**
     *  查询指定动态的所有二级评论
     */
    @Select("select " +
            "id," +
            "user_id as userId," +
            "be_comment_id as beCommentId," +
            "content,content_image as contentImage," +
            "content_video as contentVideo," +
            "root_id as rootId,p_id as pId,p_nicke as pNicke," +
            "province,city,like_count as likeCount,is_like as isLike," +
            "is_pinned as isPinned,status,del_flag as delFlag,create_by as createBy," +
            "create_time as createTime  " +
            "from mc_dynamic_comment " +
            "where root_id = #{param1} and be_comment_id = #{param2}")
    List<McDynamicComment> list2(Long root_id,Long be_comment_id);


    /***
     * 查询指定一级评论的二级评论数量
     */
    @Select("select COUNT(*) from mc_dynamic_comment where root_id = #{param1} and be_comment_id = #{param2}")
    Long getCommentNum(Long root_id,Long be_comment_id);



    /**
     * 查询指定评论的点赞数
     */
    @Select("select COUNT(*) from mc_dynamic_comment_like where be_like_works_id = #{param1} and be_like_comment_id = #{param2}")
    Long getCommentLikeNum(Long be_like_works_id,Long be_like_comment_id);

    /**
     * 当前用户是否点赞过该评论（0-未点赞,1-点赞）
     * be_like_works_id  作品id
     * be_like_comment_id  作品评论id
     * user_id 当前用户的id
     */
    @Select("select COUNT(*) from mc_dynamic_comment_like where be_like_works_id = #{param1} and be_like_comment_id = #{param2} and user_id = #{param3}")
    int getCommentCommentIsLike(Long be_like_works_id,Long be_like_comment_id,Long user_id);

}
